class Solution
{
public:
    int findTargetSumWays(vector<int> &nums, int target)
    {
        return findTargetSumWays(nums, target, nums.size() - 1);
    }

    int findTargetSumWays(vector<int> &nums, int target, int end)
    {

        int count = 0;
        if (end == 0)
        {
            count += (nums[0] == target);
            count += (nums[0] == -target);
        }
        else
        {
            count += findTargetSumWays(nums, target + nums[end], end - 1);
            count += findTargetSumWays(nums, target - nums[end], end - 1);
        }
        return count;
    }
};
